package com.accp.vehiclecare.action.lscaction;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/c/lsczfb")
public class LsczfbAction {

    final static Logger log = LoggerFactory.getLogger(LsczfbAction.class);

    @RequestMapping(value="/alipay",produces = "text/html;charset=utf-8")
    public String alipay(HttpServletRequest request, HttpServletResponse response) throws Exception {

        log.info("支付成功后的支付宝异步通知");

        // 商户订单号
        String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
        String total_amount = new String(request.getParameter("total_amount").getBytes("ISO-8859-1"), "UTF-8");

        log.info(out_trade_no);
        log.info(total_amount);
        if (!out_trade_no.equals(null)) {
            return "<script>location.href='http://localhost:8888/#/index/lsctzzf/"+out_trade_no+"/"+total_amount+"'</script>";
        } else {
            //验证失
            return "fail";
        }

    }
}
